<?php

/**
 * Earthquake filter form base class.
 *
 * @package    TMD
 * @subpackage filter
 * @author     Thaihosting
 */
abstract class BaseEarthquakeFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'SORIGIN'           => new sfWidgetFormFilterInput(),
      'SORIGIN_ENG'       => new sfWidgetFormFilterInput(),
      'DTTIME'            => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'SPROVINCE_REF'     => new sfWidgetFormFilterInput(),
      'IDIRECTION_REF'    => new sfWidgetFormFilterInput(),
      'IDISTANCE_REF'     => new sfWidgetFormFilterInput(),
      'IDEEP_UNDERGROUND' => new sfWidgetFormFilterInput(),
      'NMAGNITUDE'        => new sfWidgetFormFilterInput(),
      'ILATITUDE_DEGREE'  => new sfWidgetFormFilterInput(),
      'ILATITUDE_MINUTE'  => new sfWidgetFormFilterInput(),
      'ILATITUDE_SECOND'  => new sfWidgetFormFilterInput(),
      'ILONGITUDE_DEGREE' => new sfWidgetFormFilterInput(),
      'ILONGITUDE_MINUTE' => new sfWidgetFormFilterInput(),
      'ILONGITUDE_SECOND' => new sfWidgetFormFilterInput(),
      'SNOTE'             => new sfWidgetFormFilterInput(),
      'SNOTE_ENG'         => new sfWidgetFormFilterInput(),
      'STITLE'            => new sfWidgetFormFilterInput(),
      'STITLE_ENG'        => new sfWidgetFormFilterInput(),
      'SIMAGE_FILE'       => new sfWidgetFormFilterInput(),
      'BTMANUAL'          => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
    ));

    $this->setValidators(array(
      'SORIGIN'           => new sfValidatorPass(array('required' => false)),
      'SORIGIN_ENG'       => new sfValidatorPass(array('required' => false)),
      'DTTIME'            => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'SPROVINCE_REF'     => new sfValidatorPass(array('required' => false)),
      'IDIRECTION_REF'    => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'IDISTANCE_REF'     => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'IDEEP_UNDERGROUND' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'NMAGNITUDE'        => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'ILATITUDE_DEGREE'  => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'ILATITUDE_MINUTE'  => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'ILATITUDE_SECOND'  => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'ILONGITUDE_DEGREE' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'ILONGITUDE_MINUTE' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'ILONGITUDE_SECOND' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'SNOTE'             => new sfValidatorPass(array('required' => false)),
      'SNOTE_ENG'         => new sfValidatorPass(array('required' => false)),
      'STITLE'            => new sfValidatorPass(array('required' => false)),
      'STITLE_ENG'        => new sfValidatorPass(array('required' => false)),
      'SIMAGE_FILE'       => new sfValidatorPass(array('required' => false)),
      'BTMANUAL'          => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
    ));

    $this->widgetSchema->setNameFormat('earthquake_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Earthquake';
  }

  public function getFields()
  {
    return array(
      'IEARTHQUAKE_ID'    => 'Number',
      'SORIGIN'           => 'Text',
      'SORIGIN_ENG'       => 'Text',
      'DTTIME'            => 'Date',
      'SPROVINCE_REF'     => 'Text',
      'IDIRECTION_REF'    => 'Number',
      'IDISTANCE_REF'     => 'Number',
      'IDEEP_UNDERGROUND' => 'Number',
      'NMAGNITUDE'        => 'Number',
      'ILATITUDE_DEGREE'  => 'Number',
      'ILATITUDE_MINUTE'  => 'Number',
      'ILATITUDE_SECOND'  => 'Number',
      'ILONGITUDE_DEGREE' => 'Number',
      'ILONGITUDE_MINUTE' => 'Number',
      'ILONGITUDE_SECOND' => 'Number',
      'SNOTE'             => 'Text',
      'SNOTE_ENG'         => 'Text',
      'STITLE'            => 'Text',
      'STITLE_ENG'        => 'Text',
      'SIMAGE_FILE'       => 'Text',
      'BTMANUAL'          => 'Boolean',
    );
  }
}
